<?php

namespace Test\Controller;

use Think\Controller;

/**
 * 测试用模块index控制器
 */
class IndexController extends Controller {

    public function index() {
//        $basic = new \Com\Wechat\ChatService\BasicModel();
//        $appid = "wxab1214dbf83676a1";
//        $secert = "d7de00895ad5b1ee6b864b900142f17c";
//        $token = $basic->getAccessToken($appid, $secert);
//        $basic->getWechatServerIp($token);
    }
//
//    public function test() {
//        $xml = "<xml>
//    <ToUserName><![CDATA[gh_cf0133999d1b]]></ToUserName>
//    <Encrypt><![CDATA[Lko3pK4k6ujvkDos386hAvDEVpKEztMizUdefarmFaV+C5DImZlJJHjYLzhadoc3IEJA1rXdqdJFl8QuEJO5ETdUXzw3EBNtPSMe2Pkk9n1CTT8/Ft+nywty5dv33Smg4kZIKMpvMyF+Gxq+BQRNRnUZjtxA0fbEZ30E0eVGtBR0HS9R9TYtVc9XzyKDOd4WGkDDS55/0il3MH54XJ+5VWxq1yUnB6jPN9Cm2B0OkX447Fs5UZy0tSEJFu4WEvV8zVt1+0u1F87g4GQJ+47bjFn1RHMv3TRR0O0wKudnOts3Y8HzWp1GHBfSG2I9eu9dwgb8b9K0bZWFvmaRX8s4IvLIwbhh8y9e6admTlNS2+/ndNbaFbdbJfgT0OIxsDunrTh/ifOsc9Mm46iDA1mWKT+eFjDQDGLcS2f4HVH957U=]]></Encrypt>
//</xml>";
//        $msg_signature = "67da7171ecbfc194d82a058a0772b6095459a7f5";
//        $timestamp = 1426583049;
//        $nonce = 869687672;
//        $aeskey = "cUUWl1rzRYSLusU1RU5pAnd5qSKjhGsNPX6mwRCTQs4";
//        $token = "c3s6NfNejActNwLy";
//        $appid = "wxfea8d816ec4efe2c";
//        echo "\n=======start=========\n";
//        $crypt = new \Com\Wechat\Crypt\WxMsgCrypt($token, $aeskey, $appid);
//        $msg = "";
//        $decryptResult = $crypt->decryptMsg($msg_signature, $timestamp, $nonce, $xml, $msg);
//        echo "\n=======deresult=========\n";
//        echo $decryptResult;
//        echo "\n=======echomsg=========\n";
//        echo $msg;
//        echo "\n=======enresult=========\n";
//        $msg1 = "";
//        $encryptResult = $crypt->encryptMsg($msg, time(), mt_rand(1000000, 200000000), $msg1);
//        echo $encryptResult;
//        echo "\n=======echomsg=========\n";
//        echo $msg1;
//        echo "\n=======stop=========\n";
//    }

    public function wechat() {
        $receive = new \Com\Wechat\ChatService\ReceiveModel("wxfea8d816ec4efe2c", "c3s6NfNejActNwLy", "cUUWl1rzRYSLusU1RU5pAnd5qSKjhGsNPX6mwRCTQs4");
        $process = new \Test\Model\MyMsgProcesser();
        $receive->setProcesser($process);
        $receive->doWechat();
    }

    public function wechattest() {
        $receive = new \Com\Wechat\ChatService\ReceiveModel("wxab1214dbf83676a1", "c3s6NfNejActNwLy");
        $receive->doWechat();
    }

}
